home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_02 / scopeop.cpp < prev    next >
C/C++ Source or Header  |  1992-01-18  |  622b  |  30 lines

  1.                                       // Chapter 1 - Program 2
  2. #include <iostream.h>
  3.  
  4. int index = 13;
  5.  
  6. main()
  7. {
  8. float index = 3.1415;
  9.  
  10.    cout << "The local index value is " << index << "\n";
  11.    cout << "The global index value is " << ::index << "\n";
  12.  
  13.    ::index = index + 7;  // 3 + 7 should result in 10
  14.  
  15.    cout << "The local index value is " << index << "\n";
  16.    cout << "The global index value is " << ::index << "\n";
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23. // Result of execution
  24. //
  25. // The local index value is 3.1415
  26. // The global index value is 13
  27. // The local index value is 3.1415
  28. // The global index value is 10
  29.  
  30.